/**
 * Created by Demon on 2015/6/15.
 */
var DewPointPage = function () {
    function calculateInit() {
        Metronic.blockUI({
            boxed:true,
            message:"数据计算中..."
        });
        $.ajax({
            url: basePath + "combustion/dew-point/getCalculateInit",
            dataType: "json",
            type: "post",
            success:function() {
                $.post(basePath + "combustion/dew-point/getCalVo",function(data) {
                    $("input").autoInject({
                        data:data,
                        mode:"id"
                    });
                    Metronic.unblockUI();
                })
            }
        })
    }


    return {
        init: function () {
            calculateInit();
        },

        updata: function (ExParam) {
            var save = function (exParam, exVal) {
                if (validate.isNotNumber(exVal)) {
                    validate.invalid();
                    return;
                }
                $.ajax({
                    url: basePath + "combustion/dew-point/saveValueOfDewPointEx",
                    dataType: "json",
                    type: "post",
                    data: exParam + "=" + exVal + "&paramName=" + exParam + "&paramValue=" + exVal
                });
                validate.valid();
            };
            var $obj = $("#" + ExParam);
            var ExVal = $obj.val();
            validate.init($obj);
            if (ExVal != "") {
                save(ExParam, ExVal);
            } else {
                $.ajax({
                    url: basePath + "admin/formal/calculate",
                    dataType: "json",
                    type: "post",
                    data: "paramName=R" + ExParam,
                    success: function (data) {
                        $obj.val(data);
                        save(ExParam, data);
                        validate.valid();
                    },
                    error: function () {
                        validate.invalid();
                    }
                });

            }
        }
    }
}();